package com.yonyou.isv.demo.openapi.event.receivebill;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Sets;
import com.yonyou.isv.demo.openapi.base.module.isv.event.ISVEventListener;
import com.yonyou.isv.demo.openapi.base.network.cryptor.EncryptionHolder;
import com.yonyou.isv.demo.openapi.event.ISVEventExtendDto;
import com.yonyou.isv.demo.openapi.event.IsvEventExtendType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Set;

/**
 * @description: 收款弃审事件
 * @author: nishch
 * @create: 2021-07-26
 **/
@Slf4j
@Component
@RequiredArgsConstructor
public class ReceiveBillUnApproveEvent  implements ISVEventListener<ISVEventExtendDto> {

    @Override
    public boolean onEvent(String type, ISVEventExtendDto event, EncryptionHolder holder) {
        String content = event.getContent();
        if (StringUtils.isNotBlank(content)){
            Map map = JSON.toJavaObject(JSON.parseObject(content), Map.class);
            log.info("receive bill unApprove: {}", map);
        }
        return true;
    }

    @Override
    public Set<String> supportTypes() {
        return Sets.newHashSet(IsvEventExtendType.UN_AUDIT_RECEIVE_BILL_NOTIFY);
    }

    @Override
    public Class<ISVEventExtendDto> getEventClass() {
        return ISVEventExtendDto.class;
    }
}
